#include <Box2D.h>
#include "common.h"

#ifdef __cplusplus
extern "C" {
#endif

JNIEXPORT jint JNICALL Java_b2RopeJoint_jniGetAnchorA
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RopeJoint* joint = (b2RopeJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetAnchorA();
	return (jint)vec;
}

JNIEXPORT jint JNICALL Java_b2RopeJoint_jniGetAnchorB
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RopeJoint* joint = (b2RopeJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetAnchorB();
	return (jint)vec;
}

JNIEXPORT jfloat JNICALL Java_b2RopeJoint_jniGetReactionTorque
  (JNIEnv *env, jclass cls, jint addr, jfloat)
{
	b2RopeJoint* joint = (b2RopeJoint*)addr;
	return joint->GetReactionTorque();
}

JNIEXPORT jint JNICALL Java_b2RopeJoint_jniGetReactionForce
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RopeJoint* joint = (b2RopeJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetReactionForce();
	return (jint)vec;
}

JNIEXPORT jint JNICALL Java_b2RopeJoint_jniGetLocalAnchorA
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RopeJoint* joint = (b2RopeJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetLocalAnchorA();
	return (jint)vec;
}

JNIEXPORT jint JNICALL Java_b2RopeJoint_jniGetLocalAnchorB
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RopeJoint* joint = (b2RopeJoint*)addr;
	b2Vec2* vec = new b2Vec2();
	*vec = joint->GetLocalAnchorB();
	return (jint)vec;
}

JNIEXPORT void JNICALL Java_b2RopeJoint_jniSetMaxLength
  (JNIEnv *env, jclass cls, jint addr, jfloat length)
{
	b2RopeJoint* joint = (b2RopeJoint*)addr;
	joint->SetMaxLength(length);
}

JNIEXPORT jfloat JNICALL Java_b2RopeJoint_jniGetMaxLength
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RopeJoint* joint = (b2RopeJoint*)addr;
	return joint->GetMaxLength();
}

JNIEXPORT jint JNICALL Java_b2RopeJoint_jniGetLimitState
  (JNIEnv *env, jclass cls, jint addr)
{
	b2RopeJoint* joint = (b2RopeJoint*)addr;
	return (jint)joint->GetLimitState();
}

#ifdef __cplusplus
}
#endif
